# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=nbd
pkgver=3.24
pkgrel=1
pkgdesc="Tools for network block devices"
url="https://nbd.sourceforge.io/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	bison
	glib-dev
	gnutls-dev
	libnl3-dev
	linux-headers
	zlib-dev
	"
subpackages="$pkgname-doc $pkgname-client $pkgname-openrc"
source="https://github.com/NetworkBlockDevice/nbd/releases/download/nbd-$pkgver/nbd-$pkgver.tar.xz
	glib-2.76.patch
	nbd-server.initd
	"
options="!check" # logs very spammy (to infinite size), FIXME

# secfixes:
#   3.24-r0:
#     - CVE-2022-26495
#     - CVE-2022-26496

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-lfs \
		--enable-syslog \
		--enable-gznbd
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/nbd-server.initd \
		"$pkgdir"/etc/init.d/nbd-server
	mkdir -p "$pkgdir"/etc/nbd-server
}

client() {
	pkgdesc="$pkgdesc (client)"
	amove usr/sbin/nbd-client
}

sha512sums="
b542733ca8bdfb6883591acd5cc82fd8fa64fed7ca85b01a961e0ad69b9655750e5317df9ec510b4147cc8b0b5cdfa0b43da53dd06c42863553555d710a3c85d  nbd-3.24.tar.xz
c78efa300c5dcef405ab29b633383139e51288a142f7c2b71b266527c6668f587275f43f175861c587c9309a2267f57f99be62359b10f863c2fab1862c3a2416  glib-2.76.patch
7012adb1d822454b29d1c75cdeaab9dfa2bf0e41c058509428227953b1e555b76c1802a78e66d8fa3fc2ada932cfe265e80c90fa9dbddd544c81b1411c8ab4b4  nbd-server.initd
"
